package com.wxy.demo.controller;

import com.wxy.demo.entity.Book;
import com.wxy.demo.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author e-Xiaoyuan.Wang
 * @since 2022/10/31 11:13
 */
@RestController
@RequestMapping("/book")
@Api(tags = "书籍管理")
@Slf4j
public class BookController {

    @GetMapping("/findAll")
    @ApiOperation("查询用户书籍")
    public List<Book> findAll() {
        ArrayList<Book> list = new ArrayList<>();
        User user = new User().setUsername("张三").setAge(10);
        for (int i = 0; i < 10; i++) {
            list.add(new Book().setName("书籍" + i).setPrice((double) i).setUser(user));
        }
        return list;
    }

    @GetMapping("/deleteAll")
    @ApiOperation("批量删除")
    public List<Integer> deleteAll(@RequestBody List<Integer> ids) {
        return ids;
    }
}
